package com.example.JavaDemo.Controller;

/**
 * 接口文档访问地址 http://127.0.0.1:8089/swagger-ui/index.html
 * apifox 导入接口数据 http://127.0.0.1:8089/v2/api-docs
 */


import com.example.JavaDemo.domain.Community;
import com.example.JavaDemo.service.ICommunityService;
import com.example.comon.domain.R;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;


@RestController
@RequestMapping("/community")
@Api(value="community",tags="社区管理")
public class CommunityController {
 @Autowired
    private ICommunityService communityService;

    @GetMapping("/getCommunityList")
    @ApiOperation("查询社区")
    public R<List<Community>> getCommunityList(Community community){
        List<Community> list = communityService.selectCommunity(community);
        return R.success(list);    }

    @PostMapping("/addCommunity")
    @ApiOperation("增加社区")
    public R<Community> addCommunity(@RequestBody Community community){
        communityService.insertCommunity(community);
        return R.success(community);
    }

    @PostMapping("/updateCommunityById")
    @ApiOperation("修改社区")
    public R<List<Community>> updateCommunityById(@RequestBody Community community){
        communityService.updateCommunityById(community);
        return R.success();
    }

    @DeleteMapping("/delCommunityById")
    @ApiOperation("删除社区")
    public R<List<Community>> delCommunityById (String communityId){
        communityService.delCommunityById(communityId);
        return  R.success();
    }
}
